package org.example.leetcode;

import java.util.HashMap;

/**
 * 两数之和 : <a href="https://leetcode.cn/problems/two-sum/">...</a>
 *
 * @Author ZSL
 * @Date 2022/9/28 15:31
 * @Version 1.0
 */
public class One1 {

    public static void main(String[] args) {

    }

    public int[] twoSum(int[] nums, int target) {
        HashMap<Integer, Integer> map = new HashMap<>();
        int n = 0;
        for (int i : nums) {
            if (map.containsKey(i)) {
                return new int[]{n, map.get(i)};
            }
            map.put(target - i, n);
            n++;
        }
        return null;
    }
}
